<?php
/**
 * Created by PhpStorm.
 * User: zhangbing
 * Date: 2017/3/16 0016
 * Time: 17:00
 */
namespace app\admin\validate;
use think\Validate;

class Table extends Validate{
    //定义验证规则
    protected $rule = [
        'name'       => 'require|max:255',
        'people_num' => 'require|number|between:1,99',
        'descrip'    => 'require|max:255',
    ];

    //定义错误信息
    protected $message = [
        'name.require'       => '桌号名称不能为空',
        'name.max'           => '桌号名称不能超过255个字符',
        'people_num.require' => '容纳人数不能为空',
        'people_num.number'  => '容纳人数只能填数值',
        'people_num.between' => '容纳人数在1-99人之间',
        'descrip.require'    => '描述不能为空',
        'descrip.max'        => '描述最多255字符',
    ];

    //验证场景
    protected $scene = [
        'add'  =>  ['name','people_num','descrip'],
        'save'  =>  ['name','people_num','descrip'],
    ];
}